package com.onec.service.trade.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.onec.service.api.enums.ServiceApiEnum;
import com.onec.service.api.enums.StatusEnum;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 异步通知实体
 *
 * @author onec
 */
@Data
@Entity
@Table(name = "t_notify_order_detail")
public class NotifyOrderDetail implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true)
    private Long id;

    @Column(name = "version", length = 8)
    private Integer version;

    /**
     * 订单id
     */
    @Column(name = "agent_no", length = 11)
    private String agentNo;
    /**
     * 商户编号
     */
    @Column(name = "merchant_no", length = 32)
    private String merchantNo;

    /**
     * 下游订单号
     */
    @Column(name = "external_num", length = 32, unique = true)
    private String externalNum;

    /**
     * 上游订单号
     */
    @Column(name = "trade_num", length = 32, unique = true)
    private String tradeNum;

    /**
     * 平台流水号
     */
    @Column(name = "serial_num", length = 32, unique = true)
    private String serialNum;


    /**
     * 通知内容
     */
    @Column(name = "content", length = 1024)
    private String content;

    /**
     * 创建时间
     */
    @Column(name = "create_time", length = 0)
    @CreatedDate
    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(pattern = "yyyy-MM-dd HH:ss:mm", timezone = "GTM+8")
    private Date createTime;

    /**
     * 完成时间
     */
    @Column(name = "complete_time", length = 0)
    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(pattern = "yyyy-MM-dd HH:ss:mm", timezone = "GTM+8")
    private Date completeTime;
    /**
     * 完成时间
     */
    @Column(name = "update_time", length = 0)
    @Temporal(TemporalType.TIMESTAMP)
    @LastModifiedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:ss:mm", timezone = "GTM+8")
    private Date updateTime;

    /**
     * 交易订单通知状态
     */
    @Column(name = "status", length = 16)
    @Enumerated(EnumType.STRING)
    private StatusEnum status;

    /**
     * 产品备注
     */
    @Column(name = "remarks", length = 64)
    private String remarks;

    /**
     *
     */
    @Column(name = "front_url")
    public String frontUrl;

    @Column(name = "call_back_url")
    public String callBackUrl;

    /**
     * 通知笔数
     */
    @Column(name = "count", length = 4)
    public Integer count;

    /**
     * 返回信息
     */
    @Column(name = "return_msg")
    public String returnMsg;

    @Enumerated(EnumType.STRING)
    @Column(name = "service_api", length = 24)
    private ServiceApiEnum service;


}
